package com.stellar.auth.config;

import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

/**
 * 默认头像配置常量类
 * 通过CDN维护默认头像资源池
 */
public class DefaultUserProfileConfig {

    /**
     * 默认头像URL列表
     * 可通过增加URL扩展默认头像库
     */
    public static final List<String> DEFAULT_AVATARS;

    /**
     * 默认匿名头像URL列表
     */
    public static final List<String> DEFAULT_ANONYMOUS_AVATARS;

    /**
     * 默认昵称列表
     */
    public static final List<String> DEFAULT_NICKNAMES;

    /**
     * 默认匿名昵称列表
     */
    public static final List<String> DEFAULT_ANONYMOUS_NICKNAMES;

    static {
        List<String> avatarList = new LinkedList<>();
        avatarList.add("https://nymall.tos-cn-guangzhou.volces.com/f08f8cb9-a238-4def-872c-53dde4a9d026.png.webp");
        avatarList.add("https://nymall.tos-cn-guangzhou.volces.com/f628a607-ecdd-489f-9197-73ae8838148c.png.webp");
        avatarList.add("https://nymall.tos-cn-guangzhou.volces.com/2a7cfd27-92db-4766-9e48-1f4655267215.png.webp");
        avatarList.add("https://nymall.tos-cn-guangzhou.volces.com/67c96a76-7a55-470d-9bba-feb38e69c792.png.webp");
        avatarList.add("https://nymall.tos-cn-guangzhou.volces.com/88d5c6d4-591a-4ffc-aa37-0645da822e06.png.webp");
        avatarList.add("https://nymall.tos-cn-guangzhou.volces.com/8fee6d39-35e6-42f8-b128-4fcbb38db66d.png.webp");
        avatarList.add("https://nymall.tos-cn-guangzhou.volces.com/9fc62a07-6e3e-4ea6-adee-b7c0541b4ac2.png.webp");
        avatarList.add("https://nymall.tos-cn-guangzhou.volces.com/a2980558-613d-4a0e-aefd-f646b27b7aca.png.webp");
        avatarList.add("https://nymall.tos-cn-guangzhou.volces.com/e55b90c4-1536-484a-9d0c-ad2193932899.png.webp");
        avatarList.add("https://nymall.tos-cn-guangzhou.volces.com/c9986d38-4ac8-40ce-a725-7b3d8f35b511.png.webp");
        DEFAULT_AVATARS = avatarList;

        List<String> anonymounsAvatarList = new LinkedList<>();
        anonymounsAvatarList.add("https://nymall.tos-cn-guangzhou.volces.com/f08f8cb9-a238-4def-872c-53dde4a9d026.png.webp");
        DEFAULT_ANONYMOUS_AVATARS = anonymounsAvatarList;

        List<String> nicknameList = new LinkedList<>();
        nicknameList.add("星辰梦");
        nicknameList.add("星河韵");
        nicknameList.add("星光暖");
        nicknameList.add("星辰逸");
        nicknameList.add("星梦缘");
        nicknameList.add("星辰悦");
        nicknameList.add("星河灵");
        nicknameList.add("星光灿");
        nicknameList.add("星辰韵");
        nicknameList.add("星梦暖");
        DEFAULT_NICKNAMES = nicknameList;

        List<String> anonymousNicknameList = new LinkedList<>();
        anonymousNicknameList.add("MALO");
        DEFAULT_ANONYMOUS_NICKNAMES = anonymousNicknameList;
    }

    /**
     * 获取随机默认头像URL
     * （若需要动态扩展可改为从配置中心读取）
     */
    public static String getRandomDefaultAvatar() {
        if (DEFAULT_AVATARS.isEmpty()) {
            throw new IllegalStateException("默认头像库未配置");
        }
        return DEFAULT_AVATARS.get(ThreadLocalRandom.current().nextInt(DEFAULT_AVATARS.size()));
    }

    public static String getRandomDefaultAnonymousAvatar() {
        if (DEFAULT_ANONYMOUS_AVATARS.isEmpty()) {
            throw new IllegalStateException("默匿名头像库未配置");
        }
        return DEFAULT_ANONYMOUS_AVATARS.get(ThreadLocalRandom.current().nextInt(DEFAULT_ANONYMOUS_AVATARS.size()));
    }

    public static String getRandomDefaultNickname() {
        if (DEFAULT_NICKNAMES.isEmpty()) {
            throw new IllegalStateException("默认昵称库未配置");
        }
        return DEFAULT_NICKNAMES.get(ThreadLocalRandom.current().nextInt(DEFAULT_NICKNAMES.size()));
    }

    public static String getRandomDefaultAnonymousNickname() {
        if (DEFAULT_ANONYMOUS_NICKNAMES.isEmpty()) {
            throw new IllegalStateException("默认匿名昵称库未配置");
        }
        return DEFAULT_ANONYMOUS_NICKNAMES.get(ThreadLocalRandom.current().nextInt(DEFAULT_ANONYMOUS_NICKNAMES.size()));
    }

    // 私有构造方法防止实例化
    private DefaultUserProfileConfig() {
    }
}